﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter04.Section4
{
    public class Example04
    {
        public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            double[] q1 = {-1.0, 2.0, 2.0};
            double[] q2 = {2.0, -1.0, 2.0};
            double[] q3 = {2.0, 2.0, -1.0};

            L.Vector a1p = new L.Vector(q1);
            L.Vector a2p = new L.Vector(q2);
            L.Vector a3p = new L.Vector(q3);

            L.Vector a1 = a1p * (1.0/3.0);
            L.Vector a2 = a2p * (1.0/3.0);
            L.Vector a3 = a3p * (1.0/3.0);

            L.Vector b = new L.Vector(3);

            b[0] = 0.0;
            b[1] = 0.0;
            b[2] = 1.0;

            L.Projection proj1 = new L.Projection(a1, b);
            L.Projection proj2 = new L.Projection(a2, b);
            L.Projection proj3 = new L.Projection(a3, b);

            L.Vector res = proj1.OntoSubspace
                + proj2.OntoSubspace + proj3.OntoSubspace;

            result += res.ToString() + "\r\n";
        }
    }
}
/*
0
0
1
*/

